//轮播图
let select = document.querySelectorAll(".slideshow p a");
let show = document.querySelectorAll(".slideshow .imgs img");
let slideshow = document.querySelector(".slideshow");
let sl = document.querySelector(".slideshow .sl");
let sr = document.querySelector(".slideshow .sr");
let times;

for (let i = 0; i < select.length; i++) {
    select[i].addEventListener("mouseenter", function () {
        index = i;
        play(index);
    })
}

let index = 0;

function playtimes() {
    times = setInterval(function () {
        index++;
        if (index == show.length) {
            index = 0;
        }
        play(index);
    }, 2000)
}

playtimes();


//移入到大盒子就停止
slideshow.addEventListener("mouseenter", function () {
    clearInterval(times);
})
slideshow.addEventListener("mouseleave", function () {
    playtimes();
})


sl.addEventListener("click", function () {
    index--;
    if (index < 0) {
        index = show.length - 1;
    }
    play(index);
})
sr.addEventListener("click", function () {
    index++;
    if (index > 3) {
        index = 0;
    }
    play(index);
})

function play(index) {
    for (let j = 0; j < select.length; j++) {
        select[j].classList.remove("select");
        show[j].classList.remove("show");
    }
    select[index].classList.add("select");
    show[index].classList.add("show");
}



// 猜你喜欢
let num=0;
let la=document.querySelector(".like>p>a");
let likeSon=document.querySelectorAll(".like>div");
la.addEventListener("click",function(){
    num++;
    if(num==likeSon.length){
        num=0;
    }
    for(let i=0;i<likeSon.length;i++){
        likeSon[i].classList.remove("like-son");
    }
    likeSon[num].classList.add("like-son");

})
   
    

$(".exclusive>p a").mouseenter(function(){
    $(this).addClass("active").siblings().removeClass("active")
    let index=$(this).index()-1;
    $(this).closest(".exclusive").children("div").eq(index).addClass("exclusive-son").siblings("div").removeClass("exclusive-son");
})